package com.cooge.jiexi;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class LetvNew {

	public static void main(String[] args) throws Exception {
		
		
		String  playUrl ="http://www.letv.com/ptv/vplay/1856962.html";
		String html = NetUtil.getHtml(playUrl);
		html = html.substring(html.indexOf("mmsid")+"mmsid".length());
		html = html.substring(0, html.indexOf(",")).replaceAll("[^0-9]", "");
    	String url = "http://api.itv.letv.com/iptv/api/new/video/all/play/get.json?uid=&installVersion=1.2.2&terminalSeries=A4&wcode=cn&mac=null&terminalApplication=leso_sdk_4_tvHome&broadcastId=&bsChannel=leso_sdk_debug_4_tvHome&userFlag=null&from=DEVICE_OTHER&ph=-121&langcode=zh_cn&mmsid="+html;
    	System.out.println(url);
    	String plays =  NetUtil.getHtml(url);
    	
    	plays = plays.substring(plays.indexOf("{"), plays.lastIndexOf("}")+1);
    	
    	JSONObject jso = JSON.parseObject(plays);
    	JSONObject data = jso.getJSONObject("data");
    	JSONObject 	allPlayUrl = data.getJSONObject("allPlayUrl");
    	if(allPlayUrl.containsKey("350")){
    		System.out.println(allPlayUrl.getString("350"));
    	}
    	
    	if(allPlayUrl.containsKey("800")){
    		System.out.println(allPlayUrl.getString("800"));
    	}
    	
    	if(allPlayUrl.containsKey("1300")){
    		System.out.println(allPlayUrl.getString("1300"));
    	}
    	
    	if(allPlayUrl.containsKey("1080p6m")){
    		System.out.println(allPlayUrl.getString("1080p6m"));
    	}
    	
    	if(allPlayUrl.containsKey("720p")){
    		System.out.println(allPlayUrl.getString("720p"));
    	}
    	
	}

}
